<?php
class ome_ctl_admin_goods extends desktop_controller{

    var $workground = 'goods_manager';
    public $use_buildin_import = true;
    function index($supplier_id=null){
        
        if ($supplier_id){
            //根据供应商，获取商品列表
            $oSupplierGoods = app::get('purchase')->model('supplier_goods');
            $base_filter = $oSupplierGoods->getSupplierGoods($supplier_id);
        }
        
       $cat_id = intval($_GET['cat_id']);
       if ($cat_id){
            //按分类显示商品
            $base_filter = array('cat_id'=>$cat_id);
       }
        
        $this->finder('ome_mdl_goods',array(
            'title'=>'商品',
            //'actions'=>array(
                            //array('label'=>'添加商品','href'=>'index.php?app=ome&ctl=admin_goods_editor&act=add','target'=>'_blank'),
                        //),
            'base_filter' => $base_filter,
            //'use_buildin_new_dialog' => false,
             'use_buildin_set_tag'=>false,
             'use_buildin_recycle'=>true,
             'use_buildin_filter'=>true,
             'use_buildin_export'=>true,
            //'use_buildin_import'=>false,
           'orderBy' =>'goods_id DESC'
            ));
    }
    function view_gimage($image_id){
        $oImage = $this->app->model('image');
        $this->pagedata['image_id'] = $image_id;
        $this->display('goods/detail/img/view_gimages.html');        
    }

     function import(){      
		$oIo = kernel::servicelist('omecsv_io');
		if(!empty($oIo)){
			$this->pagedata['thisUrl'] = 'index.php?app=omecsv&ctl=admin_to_import&act=treat';
			$import = new omecsv_ctl_admin_import($this);
			$_GET['ctler']='ome_mdl_goods';
			$_GET['add']='ome';
		}else{
			$this->pagedata['thisUrl'] = 'index.php?app=ome&ctl=admin_goods&act=index';
			$import = new desktop_finder_builder_import($this);
		}
        
        $oGtype = $this->app->model('goods_type');
        $this->pagedata['gtype'] = $oGtype->getList('type_id,name');
        echo $this->page('admin/goods/download.html');
        echo "<div class=\"tableform\">";
        $import->main();
        echo "</div></div></div>";
    }
   
}
